import { http } from "@/utils/http";
import type { ResultProps } from "@/api/user";

export interface AccountProp {
  id: number;
  business_id: number;
  account: string;
  password: string;
  icon: null;
  nickname: null;
  realname: string;
  email: string;
  phone: string;
  create_time: Date;
  department: number;
  post: number;
  type: number;
  account_region_status: boolean;
  account_super_status: boolean;
  account_svip_status: boolean;
  log_share_status: boolean;
  publish_status: number;
  update_time: Date;
  verfity_status: null;
  department_name: string;
  post_name: string;
  accountstore_list: AccountstoreList[];
}

export interface AccountstoreList {
  id: number;
  store_id: null;
  account_id: number;
  business_id: number;
  group_id: number;
  assign_accountid: number;
  update_time: Date;
  create_time: Date;
}

export const accountGetList = (params?: object) => {
  return http.request<ResultProps<AccountProp[]>>("get", "/account/getList", {
    params
  });
};

export const accountAdd = (data?: object) => {
  return http.request<ResultProps<null>>("post", "/account/add", {
    data
  });
};

export const accountUpd = (data?: object) => {
  return http.request<ResultProps<null>>("post", "/account/upd", {
    data
  });
};

export const accountPublish = (data?: object) => {
  return http.request<ResultProps<null>>("post", "/account/publish", {
    data
  });
};

export interface PostProp {
  id: number;
  account_id: number;
  business_id: number;
  name: string;
  note: string;
  type: number;
  delete_status: number;
  update_time: Date;
  create_time: Date;
  power_list: string;
}

export const postGetList = (params?: object) => {
  return http.request<ResultProps<PostProp[]>>("get", "/post/getList", {
    params
  });
};

export const postAdd = (data?: object) => {
  return http.request<ResultProps<null>>("post", "/post/add", {
    data
  });
};

export const postUpd = (data?: object) => {
  return http.request<ResultProps<null>>("post", "/post/upd", {
    data
  });
};
